package com.knowif.aliOSS.enumConfig;

import com.knowif.util.commonUtil.FileUtil;
import com.knowif.util.paramUtil.DateTimeUtil;

public enum AliOSSConfig {
	
	/**
	 * 保存在阿里云oss服务的图片
	 */
	ALIIMAGE_STUDENT("knowif","image",1800000);
	
	
	
	private String bucketName;
	private String prefix;
	private String fileName;
	private String name;
	private int time;
	private AliOSSConfig(String bucketName,String prefix,int time) {
		this.bucketName = bucketName;
		this.prefix = prefix;
		this.time = time;
	}
	
	public AliOSSConfig setFileName(String fileName){
		this.fileName = fileName;
		this.name = FileUtil.getName(fileName);
		return this;
	}
	
	public String getBucketName(){
		return this.bucketName;
	}
	
	public String getFileName(){
		return this.fileName;
	}
	
	public String getPrefix() {
		return prefix;
	}

	/**
	 * 得到访问路径的过期时间
	 * @author xingyao
	 * @date 2017年4月26日
	 * @describe
	 * @return
	 */
	public int getTime() {
		return time;
	}

	/**
	 * 文件名称 包含后缀
	 * @author xingyao
	 * @date 2017年4月26日
	 * @describe
	 * @return
	 */
	public String getName() {
		return name;
	}

	public String getFilePath(){
		String suffix = FileUtil.getFileSuffix(fileName);
		int mouth = DateTimeUtil.getMonth();
		int day = DateTimeUtil.getDay();
		int hour = DateTimeUtil.getHour();
		return this.prefix+"/"+mouth+"/"+day+"/"+hour+"/"+suffix;
	}
	
}
